{extend name="admin@index_layout"/}
{block name="main"}
<style type="text/css">
    .layui-table-cell{
        height: auto!important;
        white-space: normal;
    }
</style>

<div class="layui-card">
    <div class="layui-card-header">会员列表</div>
    <div class="layui-card-body">
        <table class="layui-hide" id="currentTable" lay-filter="currentTable" 
            data-auth-add="{:$auth->check('member2.member/add')}"
            data-auth-edit="{:$auth->check('member2.member/edit')}"
            data-auth-delete="{:$auth->check('member2.member/del')}"
        ></table>
    </div>
</div>

<script type="text/html" id="picTpl">

    <img style="max-width:80px; max-height:30px;" src="{{d.avatarUrl}}" data-image="{{d.nickname}}">

</script>

<script type="text/html" id="barTool">
    <a href="javascript:;" onclick="wk.confirm('{{d.id}}','{:url('edit')}','确定切换状态吗？')" class="layui-btn layui-btn-danger layui-btn-xs" title="删除">切换账号状态</a>
<!--    <a data-open='{:url("edit")}?id={{ d.id }}' class="layui-btn layui-btn-xs layui-btn-normal {:$auth->check('member.member2/edit')?'':'layui-hide'}" title="账号设置">账号设置</a>-->
</script>

<!--操作模板-->

{/block}
{block name="script"}


<script>
layui.use('yznTable', function() {
    var table = layui.yznTable;
    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTable',
        add_url: "{:url('add')}",
        edit_url: "{:url('edit')}",
        delete_url: "{:url('del')}",
    };

    table.render({
        init: init,
        autoWidth: true,
        toolbar: ['refresh',],
        url: '{:url("index")}',
        cols: [
            [
                //昵称 nickname
                // 头像 avatarUrl
                // openid
                // 手机号 mobile
                // 性别 gender '性别:0=未知,1=男,2=女',
                // 注册ip reg_ip
                // 账号状态 status
                // 创建时间 create_time
                // { type: 'checkbox', fixed: 'left' },
                { field: 'id', width: 50, title: 'ID'},
                { field: 'nickname', Width: 110, title: '昵称',searchOp: 'like'},
                { field: 'avatarUrl', width: 100, align: "center",title: '图片', search: false, templet: '#picTpl' },
                { field: 'openid', Width: 120, title: 'openid',search: false,},
                { field: 'mobile', Width: 150, title: '手机号',},
                { field: 'order_num', width: 80, title: '订单量',},
                // { field: 'gender', Width: 90, title: '性别', templet: function(d){
                //         if(d.gender == 0){
                //             return '未知';
                //         } else if(d.gender == 1) {
                //             return '男';
                //         }else {
                //             return '女';
                //         }
                //     },search: false},
                { field: 'reg_ip', Width: 60, title: '注册ip',search: false },
                { field: 'status', Width: 90, title: '账号状态', templet: function(d){
                        if(d.status == 0){
                            return '<span style="color: red">账号停用</span>';
                        } else {
                            return '<span style="color: green">账号正常</span>';
                        }
                    }, selectList: {0: '账号停用', 1: '账号正常'}},
                { field: 'create_time', Width: 120, title: '创建时间',search: 'range' },
                { fixed: 'right',align: 'center',Width:50, title: '操作',toolbar: '#barTool' }//delete'
            ]
        ],
        page: {}
    });
    yznTable.bindevent();
});
</script>
{/block}